< previous page page_581 next page >

Page 581
8160-0581a.gif
Figure 29.1
INI file examples.
GetPrivateProfileString
The first API call youll use is GetPrivateProfileString(). This function retrieves a key value from a given section and key name. To use this function, you need to declare a buffer area to receive the value youre retrieving. Also, notice that you must assign the values of the text boxes to actual string variables, because you cannot pass the contents of a text box to a Windows API call. Heres an example using GetPrivateProfileString():
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdGet_Click()
   Dim lngRet As Long
   Dim strIni As String
   Dim strSection As String
   Dim strKeyName As String
   Dim strKeyValue As String

   strIni = Trim$(txtConfig)
   strSection = Trim$(txtSection)
   strKeyName = Trim$(txtKeyName)

   strKeyValue = Space(255)
   lngRet = GetPrivateProfileString( _
                     strSection, _
                     strKeyName, _
                     "", _
                     strKeyValue, _
                     Len(strKeyValue), _
                     strIni)

   txtKeyValue = Left$(strKeyValue, lngRet)
End Sub

 
< previous page page_581 next page >

If you like this book, buy it!